<script>
// 新增编辑页，弹窗会另抽出组件
import { defineComponent } from 'vue'
export default defineComponent({
	name: 'EditQr'
})
</script>
<script setup>
import { weekList,isEmpty } from '@/utils'
import { toRaw } from '@vue/reactivity';
import { ref,defineExpose,reactive } from 'vue'
import MyIcon from '@/components/my-icon/index.vue'
import { CircleClose,Search,CirclePlus } from '@element-plus/icons-vue'
const isRefresh = ref(true)
const props = defineProps({
  editForm: {
    type: Object,
    default: {},
  },
})
const form = ref({})
form._value = toRaw(props.editForm)
const welcomeOtherData = ref(toRaw(props.editForm).welcomeOtherData)
const formRef = ref()
const time = ref([])
if (toRaw(props.editForm).skipverify_type==2){
	if (toRaw(props.editForm).skipverify_time){
		time.value = toRaw(props.editForm).skipverify_time
	}
	
}


// 强制刷新
const handleRefresh = () => {
  isRefresh.value = false
  isRefresh.value = true
}

const getUploadImg = (val)=>{
	console.log(val,'yt9879879')
	// TODO 跨域
	form.value.image = val.url
  console.log('组件返回的img')
}
const getExposeData=() =>{
	return {
		skipverify_time:	time.value,
	}
}

const change = (e) => {};
defineExpose({
	getExposeData,
})

</script>

<template>
	<div>
		<div class="app-edit app-gap-block-top">
			<div class="app-edit-title">
				<span class="app-edit-title-words">功能设置</span>
				</div>
					<div class="app-edit-body">
				 <el-form ref="formRef" :model="form" label-width="140px">
				<el-form-item label="自动通过好友:">
					 <div class="app-flex-left">
					<el-switch  v-if="isRefresh" :active-value="1" 
      :inactive-value="0" @change="handleRefresh" size="small" v-model="form.skipverify_status" />
					<span class="app-switch-right-text">已{{ form.skipverify_status=='1'?'开启':'关闭'}}</span>
<el-popover width="" popper-style="padding: 0px;min-width:0px" placement="top" trigger="hover">
									<div class="app-container">
									开启后，客户添加该企业微信时，员工无需好友验证，将会自动添加成功
									</div>
									<template #reference>
										<MyIcon class="question-icon app-words-tip-weak" name="Question" />
									</template>
								</el-popover>
    	</div>
				</el-form-item>
<el-form-item label="开启时间:">
	<div>
				<el-radio-group
                    @change="handleRefresh"
                    v-model="form.skipverify_type"
										class="app-radio"
										v-if="isRefresh"
                  >
                    <el-radio :label="1" size="large">全天开启</el-radio>
                    <el-radio :label="2" size="large">选择时间段</el-radio>
                  </el-radio-group>
									<div v-if="form.skipverify_type == 2">
									<el-time-picker
                        size="large"
                        v-model="time"
                        is-range
                        value-format="HH:mm"
                        format="HH:mm"
                        range-separator="～"
                        start-placeholder="开始时间"
                        end-placeholder="结束时间"
											/>
												<div class="app-words-tip-weak">
										在非开启「自动通过好友」时间段添加的好友，需要客服手动通过好友验证后才可添加
									</div>
									</div>
								
									</div>
		</el-form-item>
		<el-form-item label="二维码预览:">
	<div class="app-flex-left">
				<div class="app-qrcode-img" v-if="!form.merge_qr_code"></div>
				<el-image class="app-qrcode-img" v-else :src="form.merge_qr_code" />
									<Upload :imgurl="form.image" @getImg="getUploadImg($event, val)" />
							</div>
		</el-form-item>
				</el-form>
				</div>
		
			</div>
			</div>
		
	
</template>
<style lang="scss">
	@import url('../../../../../style/app-component.scss');
	@import '../../../../../style/mixin.scss';
.app-qrcode-img{
  width: var(--app-inline-box-wh);
  height: var(--app-inline-box-wh);
	margin-right: var(--app-container-padding);
	background: url("../../../../../assets/qrcode.png");
	background-size:100% 100%; 
	background-repeat:no-repeat;
}
</style>